// Date对象 => yy年mm月
const dateFormatMonth = function (time) {
  const year = time.getFullYear()
  const month = time.getMonth() + 1
  const strMonth = month < 10 ? '0' + month : month
  return year + '年' + strMonth + '月'
}

// 时间戳 => mm月dd日 hh:mm
const formatTime = function (timeStamp) {
  let date = new Date(timeStamp)
  let month = date.getMonth() + 1// 月
  // month = month < 10 ? ('0' + month) : month
  let day = date.getDate()// 日
  day = day < 10 ? ('0' + day) : day
  let h = date.getHours()// 时
  h = h < 10 ? ('0' + h) : h
  let m = date.getMinutes()// 分
  m = m < 10 ? ('0' + m) : m
  return month + '月' + day + '日' + h + ':' + m
}

// 时间戳 => yy-mm-dd
const formatDay = function (timeStamp) {
  let date = new Date(timeStamp)
  let year = date.getFullYear()// 年
  let month = date.getMonth() + 1// 月
  month = month < 10 ? ('0' + month) : month
  let day = date.getDate()// 日
  day = day < 10 ? ('0' + day) : day
  return year + '-' + month + '-' + day
}

// 时间戳 => yy/mm/dd hh:mm:ss
const formatSpecificTime = function (timeStamp) {
  let date = new Date(timeStamp)
  let year = date.getFullYear()// 年
  let month = date.getMonth() + 1// 月
  month = month < 10 ? ('0' + month) : month
  let day = date.getDate()// 日
  day = day < 10 ? ('0' + day) : day
  let h = date.getHours()// 时
  h = h < 10 ? ('0' + h) : h
  let m = date.getMinutes()// 分
  m = m < 10 ? ('0' + m) : m
  let s = date.getSeconds()// 秒
  s = s < 10 ? ('0' + s) : s
  return year + '/' + month + '/' + day + ' ' + h + ':' + m + ':' + s
}

// 时间戳延后3天
const delayDay = function (timeStamp) {
  let time = new Date(timeStamp).getTime()
  return time + 86400000 * 3
}
// 时间戳延后随机天数（2～8天） parseInt()向下取整
// const randomDay = function (timeStamp) {
//   let time = new Date(timeStamp).getTime()
//   const random = parseInt(Math.random() * 7) + 2
//   return time + 86400000 * random
// }

// 银行卡号四位分割
// const formatBackNo = function (bankNo) {

// }
export default {
  dateFormatMonth,
  formatTime,
  formatDay,
  formatSpecificTime,
  delayDay
}
